package com.ycb.bookserver.config;


import com.book.properties.Aliossproperties;
import com.book.utils.AliOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;


@Configuration
@EnableConfigurationProperties(Aliossproperties.class)//绑定属性文件
@Slf4j
public class AliossConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public AliOssUtil aliOssUtil(Aliossproperties aliossproperties){
        log.info("开始创建阿里云文件上传工具方法:{}",aliossproperties);
       return new AliOssUtil(aliossproperties.getEndpoint(),
               aliossproperties.getAccessKeyId(),
               aliossproperties.getAccessKeySecret(),
               aliossproperties.getBucketName());
    }
}
